interface Girl {
    name: string
}

class SelectGirl<T extends Girl> {
    constructor(private girls: T[]) {
    }

    getGirl(index: number): string {
        return this.girls[index].name
    }
}

const selectGirl = new SelectGirl([
    {name: 'dajiao'},
    {name: 'liuying'},
    {name: 'xiaohong'}
])

console.log(selectGirl.getGirl(1))

// class SelectGirl<T extends number | string> {...}
// new SelectGirl<string>(['dajiao','liuying','xiaohong'])
